<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      ntp-4.2.8p14
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-2020-04-02">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 2020-04-02
      </h4>
      <h3>
        Chapter&nbsp;15.&nbsp;Networking Programs
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="netfs.html" title=
          "Configuring for Network Filesystems">Prev</a>
          <p>
            Configuring for Network Filesystems
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="rpcbind.html" title="rpcbind-1.2.5">Next</a>
          <p>
            rpcbind-1.2.5
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="netprogs.html" title=
          "Chapter&nbsp;15.&nbsp;Networking Programs">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="ntp" name="ntp"></a>ntp-4.2.8p14
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <h2 class="sect2">
          Introduction to ntp
        </h2>
        <p>
          The <span class="application">ntp</span> package contains a client
          and server to keep the time synchronized between various computers
          over a network. This package is the official reference
          implementation of the NTP protocol.
        </p>
        <p>
          This package is known to build and work properly using an LFS-9.1
          platform.
        </p>
        <h3>
          Package Information
        </h3>
        <div class="itemizedlist">
          <ul class="compact">
            <li class="listitem">
              <p>
                Download (HTTP): <a class="ulink" href=
                "https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p14.tar.gz">
                https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p14.tar.gz</a>
              </p>
            </li>
            <li class="listitem">
              <p>
                Download MD5 sum: 783edaf1d68ddf651bde64eda54a579d
              </p>
            </li>
            <li class="listitem">
              <p>
                Download size: 6.7 MB
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated disk space required: 119 MB (with tests)
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated build time: 0.7 SBU (with tests)
              </p>
            </li>
          </ul>
        </div>
        <h3>
          ntp Dependencies
        </h3>
        <h4>
          Required
        </h4>
        <p class="required">
          <a class="xref" href=
          "../general/perl-modules.html#perl-io-socket-ssl" title=
          "IO::Socket::SSL-2.068">IO-Socket-SSL-2.068</a>
        </p>
        <h4>
          Optional
        </h4>
        <p class="optional">
          <a class="xref" href="../postlfs/libcap.html" title=
          "libcap-2.33 with PAM">libcap-2.33 with PAM</a>, <a class="xref"
          href="libevent.html" title="libevent-2.1.11">libevent-2.1.11</a>,
          <a class="ulink" href=
          "http://www.thrysoee.dk/editline/">libedit</a>, and <a class=
          "ulink" href="https://www.gnu.org/software/autogen/">libopts from
          AutoGen</a>
        </p>
        <p class="usernotes">
          User Notes: <a class="ulink" href=
          "http://wiki.linuxfromscratch.org/blfs/wiki/ntp">http://wiki.linuxfromscratch.org/blfs/wiki/ntp</a>
        </p>
      </div>
      <div class="installation" lang="en" xml:lang="en">
        <h2 class="sect2">
          Installation of ntp
        </h2>
        <p>
          There should be a dedicated user and group to take control of the
          <span class="command"><strong>ntpd</strong></span> daemon after it
          is started. Issue the following commands as the <code class=
          "systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">groupadd -g 87 ntp &amp;&amp;
useradd -c "Network Time Protocol" -d /var/lib/ntp -u 87 \
        -g ntp -s /bin/false ntp</kbd>
</pre>
        <p>
          The <span class="command"><strong>update-leap</strong></span>
          command needs to be fixed in order to run properly:
        </p>
        <pre class="userinput">
<kbd class="command">sed -e 's/"(\\S+)"/"?([^\\s"]+)"?/' \
    -i scripts/update-leap/update-leap.in</kbd>
</pre>
        <p>
          Install <span class="application">ntp</span> by running the
          following commands:
        </p>
        <pre class="userinput">
<kbd class="command">./configure CFLAGS="-O2 -g -fPIC" \
            --prefix=/usr         \
            --bindir=/usr/sbin    \
            --sysconfdir=/etc     \
            --enable-linuxcaps    \
            --with-lineeditlibs=readline \
            --docdir=/usr/share/doc/ntp-4.2.8p14 &amp;&amp;
make</kbd>
</pre>
        <p>
          To test the results, issue: <span class="command"><strong>make
          check</strong></span>.
        </p>
        <p>
          Now, as the <code class="systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">make install &amp;&amp;
install -v -o ntp -g ntp -d /var/lib/ntp</kbd>
</pre>
      </div>
      <div class="commands" lang="en" xml:lang="en">
        <h2 class="sect2">
          Command Explanations
        </h2>
        <p>
          <code class="envar">CFLAGS="-O2 -g -fPIC"</code>: This environment
          variable is necessary to generate Position Independent Code needed
          for use in the package libraries.
        </p>
        <p>
          <em class="parameter"><code>--bindir=/usr/sbin</code></em>: This
          parameter places the administrative programs in <code class=
          "filename">/usr/sbin</code>.
        </p>
        <p>
          <em class="parameter"><code>--enable-linuxcaps</code></em>: ntpd is
          run as user ntp, so use Linux capabilities for non-root clock
          control.
        </p>
        <p>
          <em class=
          "parameter"><code>--with-lineeditlibs=readline</code></em>: This
          switch enables <span class="application">Readline</span> support
          for <span class="command"><strong>ntpdc</strong></span> and
          <span class="command"><strong>ntpq</strong></span> programs. If
          omitted, <span class="application">libedit</span> will be used if
          installed, otherwise no readline capabilites will be compiled.
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          Configuring ntp
        </h2>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="ntp-config" name="ntp-config"></a>
          </h3>
          <h4 class="title">
            <a id="ntp-config" name="ntp-config"></a>Config Files
          </h4>
          <p>
            <code class="filename">/etc/ntp.conf</code>
          </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3"></h3>
          <h4 class="title">
            <a id="idm140006441717024" name=
            "idm140006441717024"></a>Configuration Information
          </h4>
          <p>
            The following configuration file first defines various ntp
            servers with open access from different continents. Second, it
            creates a drift file where <span class=
            "command"><strong>ntpd</strong></span> stores the frequency
            offset and a pid file to store the <span class=
            "command"><strong>ntpd</strong></span> process ID. Third, it
            defines the location for the leap-second definition file
            <code class="filename">/etc/ntp.leapseconds</code>, that the
            <span class="command"><strong>update-leap</strong></span> script
            checks and updates, when necessary. This script can be run as a
            cron job and the <span class="application">ntp</span> developers
            recommend a frequency of about three weeks for the updates. Since
            the documentation included with the package is sparse, visit the
            ntp website at <a class="ulink" href=
            "http://www.ntp.org/">http://www.ntp.org/</a> and <a class=
            "ulink" href=
            "http://www.pool.ntp.org/">http://www.pool.ntp.org/</a> for more
            information.
          </p>
          <pre class="root">
<kbd class="command">cat &gt; /etc/ntp.conf &lt;&lt; "EOF"
<code class="literal"># Asia
server 0.asia.pool.ntp.org

# Australia
server 0.oceania.pool.ntp.org

# Europe
server 0.europe.pool.ntp.org

# North America
server 0.north-america.pool.ntp.org

# South America
server 2.south-america.pool.ntp.org

driftfile /var/lib/ntp/ntp.drift
pidfile   /var/run/ntpd.pid

leapfile  /var/lib/ntp/ntp.leapseconds</code>
EOF</kbd>
</pre>
          <p>
            You may wish to add a <span class="quote">&ldquo;<span class=
            "quote">Security session</span>&rdquo;</span>. For explanations,
            see <a class="ulink" href=
            "https://www.eecis.udel.edu/~mills/ntp/html/accopt.html#restrict">
            https://www.eecis.udel.edu/~mills/ntp/html/accopt.html#restrict</a>.
          </p>
          <pre class="root">
<kbd class="command">cat &gt;&gt; /etc/ntp.conf &lt;&lt; "EOF"
<code class="literal"># Security session
restrict    default limited kod nomodify notrap nopeer noquery
restrict -6 default limited kod nomodify notrap nopeer noquery

restrict 127.0.0.1
restrict ::1</code>
EOF</kbd>
</pre>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="ntp-init" name="ntp-init"></a>
          </h3>
          <h4 class="title">
            <a id="ntp-init" name="ntp-init"></a>Synchronizing the Time
          </h4>
          <p>
            There are two options. Option one is to run <span class=
            "command"><strong>ntpd</strong></span> continuously and allow it
            to synchronize the time in a gradual manner. The other option is
            to run <span class="command"><strong>ntpd</strong></span>
            periodically (using cron) and update the time each time
            <span class="command"><strong>ntpd</strong></span> is scheduled.
          </p>
          <p>
            If you choose Option one, then install the <span class=
            "phrase"><code class="filename">/etc/rc.d/init.d/ntp</code> init
            script</span> included in the <a class="xref" href=
            "../introduction/bootscripts.html" title=
            "BLFS Boot Scripts">blfs-bootscripts-20191204</a> package.
          </p>
          <pre class="root">
<kbd class="command">make install-ntpd</kbd>
</pre>
          <p>
            If you prefer to run <span class=
            "command"><strong>ntpd</strong></span> periodically, add the
            following command to <code class="systemitem">root</code>'s
            <code class="filename">crontab</code>:
          </p>
          <pre class="screen">
<code class="literal">ntpd -q</code>
</pre>
          <p>
            Execute the following command if you would like to set the
            hardware clock to the current system time at shutdown and reboot:
          </p>
          <pre class="root">
<kbd class=
"command">ln -v -sf ../init.d/setclock /etc/rc.d/rc0.d/K46setclock &amp;&amp;
ln -v -sf ../init.d/setclock /etc/rc.d/rc6.d/K46setclock</kbd>
</pre>
          <p>
            The other way around is already set up by LFS.
          </p>
        </div>
      </div>
      <div class="content" lang="en" xml:lang="en">
        <h2 class="sect2">
          Contents
        </h2>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">Installed Programs:</strong>
              <span class="segbody">calc_tickadj, ntp-keygen, ntp-wait, ntpd,
              ntpdate, ntpdc, ntpq, ntptime, ntptrace, sntp, tickadj and
              update-leap</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Libraries:</strong>
              <span class="segbody">None</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Directories:</strong>
              <span class="segbody">/usr/share/ntp, /usr/share/doc/ntp-4.2.8
              and /var/lib/ntp</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3>
            Short Descriptions
          </h3>
          <table border="0" class="variablelist">
            <colgroup>
              <col align="left" valign="top" />
              <col />
            </colgroup>
            <tbody>
              <tr>
                <td>
                  <p>
                    <a id="calc_tickadj" name="calc_tickadj"></a><span class=
                    "term"><span class=
                    "command"><strong>calc_tickadj</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    calculates optimal value for tick given ntp drift file.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntp-keygen" name="ntp-keygen"></a><span class=
                    "term"><span class=
                    "command"><strong>ntp-keygen</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    generates cryptographic data files used by the NTPv4
                    authentication and identification schemes.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntp-wait" name="ntp-wait"></a><span class=
                    "term"><span class=
                    "command"><strong>ntp-wait</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is useful at boot time, to delay the boot sequence until
                    <span class="command"><strong>ntpd</strong></span> has
                    set the time.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntpd" name="ntpd"></a><span class=
                    "term"><span class=
                    "command"><strong>ntpd</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a ntp daemon that runs in the background and keeps the
                    date and time synchronized based on response from
                    configured ntp servers. It also functions as a ntp
                    server.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntpdate" name="ntpdate"></a><span class=
                    "term"><span class=
                    "command"><strong>ntpdate</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a client program that sets the date and time based on
                    the response from an ntp server. This command is
                    deprecated.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntpdc" name="ntpdc"></a><span class=
                    "term"><span class=
                    "command"><strong>ntpdc</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is used to query the ntp daemon about its current state
                    and to request changes in that state.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntpq" name="ntpq"></a><span class=
                    "term"><span class=
                    "command"><strong>ntpq</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a utility program used to monitor <span class=
                    "command"><strong>ntpd</strong></span> operations and
                    determine performance.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntptime" name="ntptime"></a><span class=
                    "term"><span class=
                    "command"><strong>ntptime</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    reads and displays time-related kernel variables.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="ntptrace" name="ntptrace"></a><span class=
                    "term"><span class=
                    "command"><strong>ntptrace</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    traces a chain of ntp servers back to the primary source.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="sntp" name="sntp"></a><span class=
                    "term"><span class=
                    "command"><strong>sntp</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a Simple Network Time Protocol (SNTP) client.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="tickadj" name="tickadj"></a><span class=
                    "term"><span class=
                    "command"><strong>tickadj</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    reads, and optionally modifies, several
                    timekeeping-related variables in older kernels that do
                    not have support for precision timekeeping.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="update-leap" name="update-leap"></a><span class=
                    "term"><span class=
                    "command"><strong>update-leap</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a script to verify and, if necessary, update the
                    leap-second definition file.
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <p class="updated">
        Last updated on 2020-03-22 10:52:07 -0500
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="netfs.html" title=
          "Configuring for Network Filesystems">Prev</a>
          <p>
            Configuring for Network Filesystems
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="rpcbind.html" title="rpcbind-1.2.5">Next</a>
          <p>
            rpcbind-1.2.5
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="netprogs.html" title=
          "Chapter&nbsp;15.&nbsp;Networking Programs">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
